import pymysql


conn = pymysql.connect(host='localhost',
                       port=3306, password='qaz3357375', user='root',
                       db='test')

cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
sql = "select id, name from users where name='{}' and pwd='{}'".format('alex', '123')
print(sql)
cursor.execute(sql)
obj = cursor.fetchone()
conn.commit()
cursor.close()
conn.close()

print(obj)

